package leetcode.code2017;

import leetcode.IDebug;

public class Solution implements IDebug {

	public long gridGame(int[][] grid) {
		int n = grid[0].length;
		long[] r0 = new long[n];
		long[] r1 = new long[n];
		r0[0] = grid[0][0];
		r1[0] = grid[1][0];
		for (int i = 1; i < n; i++) {
			r0[i] = r0[i - 1] + grid[0][i];
			r1[i] = r1[i - 1] + grid[1][i];
		}
		long ans = r0[n - 1] - r0[0];
		for (int i = 1; i < n - 1; i++) {
			ans = Math.min(ans, Math.max(r1[i - 1], r0[n - 1] - r0[i]));
		}
		if (n - 2 >= 0) {
			ans = Math.min(ans, r1[n - 2]);
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Integer num = 1000;
		Integer num1 = 1000;
		System.out.println(num == 1000);
		System.out.println(num > 100);

	}

}
